<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取已注册的流类型</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.stream-get-transports.html">« stream_get_transports</a></li>
      <li style="float: right;"><a href="function.stream-is-local.html">stream_is_local »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.stream.html">Stream 函数</a></li>
    <li>获取已注册的流类型</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.stream-get-wrappers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_get_wrappers</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_get_wrappers</span> &mdash; <span class="dc-title">获取已注册的流类型</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-get-wrappers-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_get_wrappers</strong></span>(): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   获取在当前运行系统中已经注册并可使用的流类型列表。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-get-wrappers-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-get-wrappers-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个索引数组，该数组里包含了当前运行系统中可使用的流类型的名称。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.stream-get-wrappers-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3772">
    <p><strong>示例 #1 <span class="function"><strong>stream_get_wrappers()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">stream_get_wrappers</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; php
    [1] =&gt; file
    [2] =&gt; http
    [3] =&gt; ftp
    [4] =&gt; compress.bzip2
    [5] =&gt; compress.zlib
)
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3773">
    <p><strong>示例 #2 检查一个流类型是否存在</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;检查是否存在&nbsp;bzip2&nbsp;流包装器<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">in_array</span><span style="color: #007700">(</span><span style="color: #DD0000">'compress.bzip2'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">stream_get_wrappers</span><span style="color: #007700">()))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'compress.bzip2://&nbsp;support&nbsp;enabled.'</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'compress.bzip2://&nbsp;support&nbsp;not&nbsp;enabled.'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-get-wrappers-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.stream-wrapper-register.html" class="function" rel="rdfs-seeAlso">stream_wrapper_register()</a> - 注册一个用 PHP 类实现的 URL 封装协议</span></li>
  </ul>
 </div>

</div></div></div></body></html>